/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.siagefi.mb;

import br.siagefi.model.TipoNotaFiscal;
import br.siagefi.service.TipoNotaFiscalService;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Paulo Lavarini
 */
@ManagedBean
@SessionScoped
public class TipoNotaFiscalBean implements Serializable{
    
   private TipoNotaFiscal tipoNotaFiscal;
   private final TipoNotaFiscalService service;
   private List<TipoNotaFiscal> tipoNotasFiscais;

    public TipoNotaFiscalBean() {
        this.tipoNotaFiscal = new TipoNotaFiscal();
        this.service = new TipoNotaFiscalService();
        this.carregarLista();
    }
    
     public final void carregarLista(){
         this.tipoNotasFiscais = service.listar();
    }
    
    public String gravar(){
        service.inserir(this.getTipoNotaFiscal());
        this.limparFormularioDoJsf();
        this.carregarLista();
        return "tipoNotaFiscal?faces-redirect=true";
    }
    
    public String alterar(TipoNotaFiscal tipoNotaFiscal){
        this.setTipoNotaFiscal(tipoNotaFiscal);
        return "incluirTipoNotaFiscal";
    }
    
     public String remover(){
        service.remover(this.getTipoNotaFiscal());
        this.limparFormularioDoJsf();
        this.carregarLista();
        return "tipoNotaFiscal";
    }
     
    public String remover(TipoNotaFiscal tipoNotaFiscal){
        service.remover(tipoNotaFiscal);
        this.limparFormularioDoJsf();
        this.carregarLista();
        return "tipoNotaFiscal";
    }
  
    public void limparFormularioDoJsf(){
        this.tipoNotaFiscal = new TipoNotaFiscal();
    }

    public TipoNotaFiscal getTipoNotaFiscal() {
        return tipoNotaFiscal;
    }

    public void setTipoNotaFiscal(TipoNotaFiscal tipoNotaFiscal) {
        this.tipoNotaFiscal = tipoNotaFiscal;
    }

    public List<TipoNotaFiscal> getTipoNotasFiscais() {
        return tipoNotasFiscais;
    }

    public void setTipoNotasFiscais(List<TipoNotaFiscal> tipoNotasFiscais) {
        this.tipoNotasFiscais = tipoNotasFiscais;
    }
    
    
}
